package cc.yugu.yhdw.webserver.service.hdw;


import cc.yugu.yhdw.common.constant.CacheKey;
import cc.yugu.yhdw.common.domain.hdw.Supplier;
import cc.yugu.yhdw.common.domain.hdw.SupplierInfo;
import cc.yugu.yhdw.common.tool.memcached.MemCachedConfig;
import com.whalin.MemCached.MemCachedClient;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
 * 厂商业务切面类
 * 
 * @Date:Created in 2018/7/10 17:21
 * @Author:
 * @Modified By: zjn 2018/7/10 17:21
 */ 
@Component
@Aspect
public class SupplierServiceAspect {

    @Autowired
    MemCachedClient memCachedClient;

    @Pointcut("execution(* cc.yugu.yhdw.webserver.service.hdw.SupplierService.update(..))")
    private void update() {}
    /**
    * 更新
    * 
    * @Param: [joinPoint]
    * @Return: java.lang.Object
    * @Author By: zjn 2018/7/10  17:21
    */ 
    @Around("update()")
    public Object update(ProceedingJoinPoint joinPoint) throws Throwable {
        Supplier supplier = (Supplier) joinPoint.getArgs()[0];
        Object result = joinPoint.proceed();

        String key = CacheKey.key(CacheKey.K_ID_V_SUPPLIER_INFO, supplier.getId());
        memCachedClient.delete(key);
        return result;
    }
}
